package com.softline.documentsmall.service.impl;

import com.softline.documentsmall.dao.ZsIndexReportMapper;
import com.softline.documentsmall.entity.ZsIndexReport;
import com.softline.documentsmall.ret.ReturnVO;
import com.softline.documentsmall.ret.ReturnVOUtils;
import com.softline.documentsmall.service.ZsIndexReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author zhongweicheng
 * @DATE 2021-03-19
 */
@Service
@Slf4j
public class ZsIndexReportServiceImpl implements ZsIndexReportService {

    @Autowired
    ZsIndexReportMapper zsIndexReportMapper;

    @Override
    public ReturnVO findZsReportInfo(String year,String areaType,String type) {
        return ReturnVOUtils.success(zsIndexReportMapper.findZsReportInfo(year,areaType,type));
    }

    @Override
    public ReturnVO deleteZsReportInfoById(Integer id) {
       try{
           zsIndexReportMapper.deleteZsReportInfoById(id);
       }catch (Exception e){
           log.error("ZsIndexReportServiceImpl deleteZsReportInfoById error!");
           return ReturnVOUtils.businessFailCustom(201,e.getMessage());
       }
       return ReturnVOUtils.success("delete success");

    }

    @Override
    public ReturnVO insertZsReportInfo(ZsIndexReport zsIndexReport) {
        try{
            zsIndexReportMapper.insertZsReportInfo(zsIndexReport);
        }catch (Exception e){
            log.error("ZsIndexReportServiceImpl insertZsReportInfo error!");
            return ReturnVOUtils.businessFailCustom(201,e.getMessage());
        }
        return ReturnVOUtils.success("insert success");
    }

    @Override
    public ReturnVO updateZsReportInfo(ZsIndexReport zsIndexReport) {
        try{
            zsIndexReportMapper.updateZsReportInfo(zsIndexReport);
        }catch (Exception e){
            log.error("ZsIndexReportServiceImpl updateZsReportInfo error!");
            return ReturnVOUtils.businessFailCustom(201,e.getMessage());
        }
        return ReturnVOUtils.success("update success");
    }
}

